package com.mallcai.bigdata.ladon.controller.common.form;

import com.mallcai.bigdata.ladon.controller.BaseForm;
import com.mallcai.bigdata.ladon.dpl.entity.common.CommonInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * Created by oneape<oneape15@163.com>
 * Created 2019-05-22 11:16.
 * Modify:
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class CommonInfoForm extends BaseForm {
    @NotNull(message = "主键Id不能为空", groups = {IdCheck.class, EditCheck.class})
    private Long   commonInfoId;
    @NotBlank(message = "分类不能为空", groups = {AddCheck.class, EditCheck.class, ClassifyCheck.class})
    private String classify;  // 分类
    @NotBlank(message = "名称不能为空", groups = {AddCheck.class, EditCheck.class})
    private String name;      // 名称
    @NotBlank(message = "编码不能为空", groups = {AddCheck.class, EditCheck.class})
    private String code;      // 编码
    private Long parentClassify;      // 父分类

    public CommonInfo toEntity() {
        CommonInfo ci = new CommonInfo();

        BeanUtils.copyProperties(this, ci);
        ci.setId(commonInfoId);
        return ci;
    }

    public interface IdCheck {
    }

    public interface AddCheck {
    }

    public interface EditCheck {
    }

    public interface ClassifyCheck {
    }

}
